/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 */

package com.xci.edu.core.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.github.lvyanyang.core.BaseOperateUserEntity;
import com.github.lvyanyang.core.Const;
import com.github.lvyanyang.core.XCI;
import com.github.lvyanyang.validator.IdCard;
import com.github.lvyanyang.validator.MobilePhoneNumber;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 学员信息
 * @author 张谦 zhangqian@xci96716.com
 * @since 2020-11-24 15:29:29
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "学员信息")
public class EduStudent extends BaseOperateUserEntity {
    /**
     * 主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ExcelIgnore
    @Excel(name = "主键", width = 20d)
    @ApiModelProperty(value = "主键", position = 1)
    private Long id;

    /**
     * 学员姓名
     */
    @NotBlank(message = "学员姓名不能为空")
    @Length(max = 50, message = "学员姓名长度不能超过{max}个字符")
    @Excel(name = "学员姓名", width = 20d)
    @ApiModelProperty(value = "学员姓名", required = true, position = 2)
    private String name;

    /**
     * 学员密码
     */
    @Length(max = 50, message = "学员密码长度不能超过{max}个字符")
    @ApiModelProperty(value = "学员密码", required = true, position = 3)
    private String pwd;

    /**
     * 姓名简拼
     */
    @Length(max = 100, message = "姓名简拼长度不能超过{max}个字符")
    @Excel(name = "姓名简拼", width = 10d)
    @ApiModelProperty(value = "姓名简拼", position = 4)
    private String spell;

    /**
     * 性别
     */
    @Length(max = 10, message = "性别长度不能超过{max}个字符")
    @Excel(name = "性别", width = 5d)
    @ApiModelProperty(value = "性别", position = 5)
    private String sex;

    /**
     * 身份证号码
     * 身份证校验 必须加
     */
    @IdCard
    @NotBlank(message = "身份证号码不能为空")
    @Length(max = 20, message = "身份证号码长度不能超过{max}个字符")
    @Excel(name = "身份证号码", width = 20d)
    @ApiModelProperty(value = "身份证号码", required = true, position = 6)
    private String idNumber;

    /**
     * 手机号码
     */
    @MobilePhoneNumber
    @NotBlank(message = "手机号码不能为空")
    @Length(max = 50, message = "手机号码长度不能超过{max}个字符")
    @Excel(name = "手机号码", width = 20d)
    @ApiModelProperty(value = "手机号码", required = true, position = 7)
    private String phone;

    /**
     * 电子邮件
     */
    @Email
    @Length(max = 50, message = "电子邮件长度不能超过{max}个字符")
    @Excel(name = "电子邮件", width = 20d)
    @ApiModelProperty(value = "电子邮件", position = 8)
    private String email;

    /**
     * 地址
     */
    @Length(max = 200, message = "地址长度不能超过{max}个字符")
    @Excel(name = "地址", width = 20d)
    @ApiModelProperty(value = "地址", position = 9)
    private String address;

    /**
     * 科目主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "科目主键不能为空")
    @ApiModelProperty(value = "科目主键", required = true, position = 10)
    private Long eduCategoryId;

    /**
     * 科目名称
     */
    @NotBlank(message = "科目名称不能为空")
    @Length(max = 50, message = "科目名称长度不能超过{max}个字符")
    @Excel(name = "科目", width = 20d)
    @ApiModelProperty(value = "科目名称", required = true, position = 11)
    private String eduCategoryName;

    /**
     * 培训计划主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "培训计划主键", position = 12)
    private Long planId;

    /**
     * 培训计划名称
     */
    @Length(max = 10, message = "培训计划名称长度不能超过{max}个字符")
    @Excel(name = "培训计划", width = 20d)
    @ApiModelProperty(value = "培训计划名称", position = 13)
    private String planName;

    /**
     * 已培训总学时(秒)
     */
    @Excel(name = "已培训总学时(秒)", width = 20d)
    @ApiModelProperty(value = "已培训总学时(秒)", position = 14)
    private Integer trainTotalPeriod;

    /**
     * 状态 [0-预报名, 1-报名中, 2-学习中, 3-准备考试, 4-考试中, 5-完成]
     */
    @NotNull(message = "状态 不能为空")
    @Excel(name = "状态 ", width = 20d, replace = { "预报名_0", "报名中_1", "学习中_2", "准备考试_3", "考试中_4", "完成_5" })
    @ApiModelProperty(value = "状态 ", required = true, position = 15)
    private Integer status;

    /**
     * 状态文本
     */
    @ApiModelProperty(value = "状态文本", position = 12)
    private String statusText;

    /**
     * 状态文本
     */
    public String getStatusText() {
        if(XCI.isEmpty(status)){
            return Const.Empty;
        }
        switch (status) {
            case 0:
                return "预报名";
            case 1:
                return "报名中";
            case 2:
                return "学习中";
            case 3:
                return "准备考试";
            case 4:
                return "考试中";
            case 5:
                return "完成";
        }
        return Const.Empty;
    }

    /**
     * 备注
     */
    @Length(max = 500, message = "备注长度不能超过{max}个字符")
    @ApiModelProperty(value = "备注", position = 16)
    private String remark;
}